<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:wh="http://java.sun.com/jsf/composite/wh"
	xmlns:p="http://primefaces.org/ui">

<h:body>
	<ui:composition template="template/template.xhtml">
		<ui:define name="content">
			<h:form id="reportForm">
				<h:panelGrid columns="1">
					<p:breadCrumb>
					<p:menuitem value="Categories" url="adminGameStatisticsManagement.xhtml#" />
					<p:menuitem value="#{adminMBean.selectedGame.name}"
						url="adminGameStatisticsManagement.xhtml#" />
					</p:breadCrumb>
					
					<h1>Game Statistic Tables</h1>
					
					<p:selectOneMenu value="#{adminMBean.selectedReportOption}">
						<f:selectItem itemLabel="Select One" itemValue="" />
						<f:selectItems value="#{adminMBean.reportOptions}"/>
					</p:selectOneMenu>
					
					<p:commandButton id="cmdGenerate" value="Generate" update="reportTable" actionListener="#{adminMBean.eventLoadTableData}"></p:commandButton>

					
					<p:dataTable id="reportTable" var="infos" value="#{adminMBean.tableData}" 
						paginatorTemplate="{RowsPerPageDropdown} {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
						rowsPerPageTemplate="10,25,50,100" paginator="true" rows="100"  >
						
						<f:facet name="{Exporters}" >
							<h:commandLink>
								<p:graphicImage library="img" name="excel.png" width="24"/>
								<p:dataExporter type="xls" target="reportTable" fileName="statistic"
									pageOnly="false" />
							</h:commandLink>
							<h:commandLink>
								<p:graphicImage library="img" name="pdf.png" width="24"/>
								<p:dataExporter type="pdf" target="reportTable" fileName="statistic"
									pageOnly="false" />
							</h:commandLink>
						</f:facet>
						
						<p:columns value="#{adminMBean.columns}" var="column" filterBy="#{infos[column.property]}"
							sortBy="#{infos[column.property]}" headerText="#{column.header}" >
							<h:outputText value="#{infos[column.property]}" />
						</p:columns>
						
						<f:facet name="footer">
				           Total rows: #{adminMBean.tableData.size()}
				        </f:facet>
						
					</p:dataTable>
						
				</h:panelGrid>
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>